<%- include myCenterHeader.ejs %>
<h3 style="color: #d77a03"><b><%= __('mycenter').r_intive%></b></h3>

<div style="font-size: 18px;color: #9d9d9d;margin-top: 50px">
    <% if(datas.length==0){%>
    <div style="height: 200px;text-align: center">
        <span style="line-height: 200px"><%= __('findPartner').hint %>!!!!</span>
    </div>
    <hr style="border: none;border-top: 2px dotted #cac9c4;margin-left: -65px" >
    <%}%>
    <% datas.forEach(function(data,index){%>
    <span style="display: block">
        <div style="width: 70%;float: left">
            <!--<span style="line-height: 35px"><%- data.orderUser.nickname%><%= __('orderList').m2 %><% if(data.orderToUser.username ==user.username){ %>我<% }else {%><%- data.orderToUser.nickname%><% } %>在<%- data.orderCalendar.start%><%- data.orderCoffee.addr%><%- data.orderCoffee.name%>咖啡馆见面</span>-->
            <span style="line-height: 35px"><%- data.orderUser.nickname%><%= __('orderList').m2 %><%= __('myOrderList').m1 %><%- data.orderCalendar.start%><%= __('orderList').m3 %><%- data.orderCoffee.addr%><%- data.orderCoffee.name%><%= __('orderList').m4 %></span>
        </div>
        <% if(data.orderToUser.username ==user.username&&data.state==0){ %>
        <div style="width: 25%;float: left;margin-left: 2px">
            <a class="btn btn-primary" onclick="changState('<%- data._id%>',1)" ><%= __('myOrderList').accept %></a>
            <a class="btn btn-danger" onclick="changState('<%- data._id%>',2)"><%= __('myOrderList').refuse %></a>
        </div>
        <% } %>
    </span>
    <div style="clear: both"></div>
    <div style="width: 100px;float: left;margin-top: 20px">
        <img class="img-rounded" src="<%- data.orderUser.headSrc%>" style="width: 60px;height: 60px">
    </div>
    <div style="margin-top: 20px;">
        <div style="width: 200px;float: left">
            <span style=""><%= __('partnerCenter').username %>：<%- data.orderUser.nickname%></span><br>
            <span><%= __('partnerCenter').m_language %>：<%- data.orderUser.language%></span><br>
            <span><%= __('partnerCenter').addr %>：<%- data.orderUser.nowcity%></span>
        </div>
        <div style="width: 200px;float: left">
            <span><%= __('partnerCenter').gender %>：<% if(data.orderUser.gender==0){%>女<%}else{%>男<%}%></span><br>
            <span><%= __('partnerCenter').age %>：<%- data.orderUser.age%></span><br>
            <span><%= __('partnerCenter').learn_language %>：<%- data.orderUser.studylanguage%></span>
        </div>
    </div>

    <div style="clear: both;height: 20px"></div>
    <div style="float: left;margin-right: 20%;">
        <span style="font-size: 14px;color: #fca81a"><b><% if(data.state==0){%><%= __('orderList').state0 %><%}else if(data.state==1){%><%= __('orderList').state1 %><%}else{%><%= __('orderList').state2 %><%}%></b></span>
    </div>
    <div style="float: right;margin-right: 20%;">
        <span style="font-size: 14px;color: #fca81a"><b><%-data.orderDate.format('yyyy.MM.dd hh:mm:ss')%></b></span>
    </div>
    <hr style="border: none;border-top: 2px dotted #cac9c4;margin-left: -65px" >
    <% }) %>
</div>

<div class="span12">
    <div id="page1"></div>
</div>
<%- include myCenterFooter.ejs %>
<script>
    function changState(id,state){
        var prompt=confirm("<%= __("myOrderList").alert%>？？");

        if(prompt){

            window.location.href="/changOrderState?id="+id+"&state="+state;
        }
    }
    $(function(){
        //获得浏览器参数

        $.extend({
            getUrlVars: function(){
                var vars = [];
                var hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                console.log(hashes);
                for(var i = 0; i < hashes.length; i++){
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            },
            getUrlVar: function(name){
                return $.getUrlVars()[name];
            }
        });

        //封装浏览器参数
        var composeUrlParams=function(){
            var param='';
            $.each($.getUrlVars(), function(i, item) {
                if(item!='num'){
                    var val=$.getUrlVar(item);
                    if(val) param += "&" + item+"="+val;
                }
            });
            return param;
        }
        var options = {
            currentPage:<%- page.num %>,                //当前页，css样式同其他页不同
            totalPages:<%- page.pageCount %>,           //总页数
            numberOfPages:5,                            //导航最多显示页数
            pageUrl: function(type, page, current) {    //页面跳转
                if(page!=<%- page.num %>){
                    return "/myOrderList?num="+ page+composeUrlParams();
                }

            }
        }
        $('#page1').bootstrapPaginator(options);
        WdatePicker({eCont:'showDate',onpicked:function(dp){
            alert('你选择的日期是:'+dp.cal.getDateStr());
        }
        })
    })
</script>